<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="/commonjsp/common.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>My JSP 'autocomplete.jsp' starting page</title>
  <script type="text/javascript">
  	layer.msg("welcome to");
  	$('#autocompleteInput').autocomplete({
        source:function(query,process){
            var matchCount = this.options.items;//返回结果集最大数量
            $.post("/test/getAutoDatas",{"matchInfo":query,"matchCount":matchCount},function(respData){
                return process(respData);
            });
        },
        formatItem:function(item){
            return item["regionName"]+item["regionCode"];
        },
        setValue:function(item){
            return {'data-value':item["regionName"],'real-value':item["regionCode"]};
        }
    });
 
	$("#goBtn").click(function(){ //获取文本框的实际值
        var regionCode = $("#autocompleteInput").attr("real-value") || "";
        alert(regionCode);
    });
  </script>
  </head>
  	<input type="text" id="autocompleteInput" name="autocompleteInput" value="">
  	<button id="goBtn">GO</button>
  <body>
     
  </body>
</html>
